#include "lolevel.h"
#include "platform.h"
#include "core.h"

static long *nrflag = (long*)0xBF94;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FFE96FA8_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"
                "MOV     R4, R0\n"
                "SUB     SP, SP, #0xC\n"
                "BL      sub_FFE97A18\n"
                "MVN     R1, #0\n"
                "BL      sub_FFEA7FA8\n"
                "MOV     R0, #0x8A\n"
                "ADD     R1, SP, #4\n"
                "MOV     R2, #4\n"
                "BL      sub_FFC0BCB8\n"
                "TST     R0, #1\n"
                "BEQ     loc_FFE96FE8\n"
                "MOV     R1, #0x1D0\n"
                "LDR     R0, =0xFFE96E2C\n"
                "ADD     R1, R1, #2\n"
                "BL      sub_FFEB5664\n"
"loc_FFE96FE8:\n"                           
                "LDR     R3, =0xA4BA0\n"
                "LDR     R2, =0xA4C60\n"
                "LDR     R0, [R3,#0x74]\n"
                "LDRSH   R1, [R2,#0xE]\n"
                "BL      sub_FFDE52F8\n"
                "MOV     R0, R4\n"
                "BL      sub_FFE96DB0\n"
                "BL      wait_until_remote_button_is_released\n"
                "BL      capt_seq_hook_set_nr\n" // +
                "LDR     R3, =0xBF98\n"
                "LDR     R0, [R3]\n"

                "B       sub_FFE9700C\n"  // ---> jump to end of function in ROM
    );
}

void __attribute__((naked,noinline)) sub_FFE93F70_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"
                "LDR     R4, [R0,#0xC]\n"
                "LDR     R3, [R4,#8]\n"
                "ORR     R3, R3, #1\n"
                "STR     R3, [R4,#8]\n"
                "MOV     R0, #0xC\n"
                "BL      sub_FFE9E130\n"
                "TST     R0, #1\n"
                "MOV     R0, #1\n"
                "MOV     R2, R4\n"
                "MOV     R1, R0\n"
                "BEQ     loc_FFE93FB4\n"
                "LDR     R3, [R4,#8]\n"
                "ORR     R3, R3, #0x40000000\n"
                "STR     R3, [R4,#8]\n"
                "LDMFD   SP!, {R4,LR}\n"
                "B       sub_FFE927E4\n"
"loc_FFE93FB4:\n"                           
                "BL      sub_FFE94A48\n"
                "MOV     R0, R4\n"
                "BL      sub_FFE95AAC\n"
                "TST     R0, #1\n"
                "MOV     R2, R4\n"
                "MOV     R1, #1\n"
                "BEQ     loc_FFE93FD8\n"
                "LDMFD   SP!, {R4,LR}\n"
                "B       sub_FFE927E4\n"
"loc_FFE93FD8:\n"                           
                "BL      sub_FFC15FF0\n"
                "BL      sub_FFC0BEB4\n"
                "STR     R0, [R4,#0x14]\n"
                "MOV     R0, R4\n"
                "BL      sub_FFE96E90\n"
                "BL      sub_FFE97884\n"
                "MOV     R0, R4\n"
                "BL      sub_FFE96FA8_my\n"  //---------->
                "BL      capt_seq_hook_raw_here\n"  // +
                "MOV     R1, #1\n"
                "MOV     R2, R4\n"
                "BL      sub_FFE927E4\n"
                "BL      sub_FFE97324\n"
                "CMP     R0, #0\n"
                "LDRNE   R3, [R4,#8]\n"
                "ORRNE   R3, R3, #0x2000\n"
                "STRNE   R3, [R4,#8]\n"
                "LDMFD   SP!, {R4,PC}\n"
    );
}

void __attribute__((naked,noinline)) capt_seq_task()
{
	asm volatile (
                "STMFD   SP!, {R4,LR}\n"
                "SUB     SP, SP, #4\n"
                "MOV     R4, SP\n"
                "B       loc_FFE944E0\n"
"loc_FFE94384:\n"                           
                "LDR     R2, [SP]\n"
                "LDR     R3, [R2]\n"
                "MOV     R0, R2\n"
                "CMP     R3, #0x15\n"
                "LDRLS   PC, [PC,R3,LSL#2]\n"
                "B       loc_FFE944B4\n"
                ".long loc_FFE943F4\n"
                ".long loc_FFE94400\n"
                ".long loc_FFE94408\n"
                ".long loc_FFE9441C\n"
                ".long loc_FFE94414\n"
                ".long loc_FFE94424\n"
                ".long loc_FFE9442C\n"
                ".long loc_FFE94438\n"
                ".long loc_FFE94440\n"
                ".long loc_FFE9444C\n"
                ".long loc_FFE94454\n"
                ".long loc_FFE9445C\n"
                ".long loc_FFE94464\n"
                ".long loc_FFE9446C\n"
                ".long loc_FFE94474\n"
                ".long loc_FFE94480\n"
                ".long loc_FFE94488\n"
                ".long loc_FFE94490\n"
                ".long loc_FFE94498\n"
                ".long loc_FFE944A4\n"
                ".long loc_FFE944AC\n"
                ".long loc_FFE944C8\n"
"loc_FFE943F4:\n"                           
                                        
                "BL      sub_FFE94A5C\n"
                "BL      shooting_expo_param_override\n"   // +
                "BL      sub_FFE922D8\n"
                "B       loc_FFE944C4\n"
"loc_FFE94400:\n"                           
                                        
                "BL      sub_FFE93F70_my\n"  //--------->
                "B       loc_FFE944C4\n"
"loc_FFE94408:\n"                           
                                        
                "MOV     R0, #1\n"
                "BL      sub_FFE94C58\n"
                "B       loc_FFE944C4\n"
"loc_FFE94414:\n"                           
                                        
                "BL      sub_FFE945C4\n"
                "B       loc_FFE944C4\n"
"loc_FFE9441C:\n"                           
                                        
                "BL      sub_FFE94A28\n"
                "B       loc_FFE944C4\n"
"loc_FFE94424:\n"                           
                                        
                "BL      sub_FFE94A38\n"
                "B       loc_FFE944C4\n"
"loc_FFE9442C:\n"                           
                                        
                "BL      sub_FFE94B50\n"
                "BL      sub_FFE922D8\n"
                "B       loc_FFE944C4\n"
"loc_FFE94438:\n"                           
                                        
                "BL      sub_FFE94080\n"
                "B       loc_FFE944C4\n"
"loc_FFE94440:\n"                           
                                        
                "BL      sub_FFE94BC0\n"
                "BL      sub_FFE922D8\n"
                "B       loc_FFE944C4\n"
"loc_FFE9444C:\n"                           
                                        
                "BL      sub_FFE94A28\n"
                "B       loc_FFE944C4\n"
"loc_FFE94454:\n"                           
                                        
                "BL      sub_FFE961E0\n"
                "B       loc_FFE944C4\n"
"loc_FFE9445C:\n"                           
                                        
                "BL      sub_FFE963B4\n"
                "B       loc_FFE944C4\n"
"loc_FFE94464:\n"                           
                                        
                "BL      sub_FFE96448\n"
                "B       loc_FFE944C4\n"
"loc_FFE9446C:\n"                           
                                        
                "BL      sub_FFE96544\n"
                "B       loc_FFE944C4\n"
"loc_FFE94474:\n"                           
                                        
                "MOV     R0, #0\n"
                "BL      sub_FFE967B0\n"
                "B       loc_FFE944C4\n"
"loc_FFE94480:\n"                           
                                        
                "BL      sub_FFE96984\n"
                "B       loc_FFE944C4\n"
"loc_FFE94488:\n"                           
                                        
                "BL      sub_FFE96A20\n"
                "B       loc_FFE944C4\n"
"loc_FFE94490:\n"                           
                                        
                "BL      sub_FFE96AE0\n"
                "B       loc_FFE944C4\n"
"loc_FFE94498:\n"                           
                                        
                "BL      sub_FFE94DB4\n"
                "BL      sub_FFE93E94\n"
                "B       loc_FFE944C4\n"
"loc_FFE944A4:\n"                           
                                        
                "BL      sub_FFE96684\n"
                "B       loc_FFE944C4\n"
"loc_FFE944AC:\n"                           
                                        
                "BL      sub_FFE966E0\n"
                "B       loc_FFE944C4\n"
"loc_FFE944B4:\n"                           
                "MOV     R1, #0x4C0\n"
                "LDR     R0, =0xFFE93CF0\n"
                "ADD     R1, R1, #0xE\n"
                "BL      sub_FFEB5664\n"
"loc_FFE944C4:\n"                           
                                        
                "LDR     R2, [SP]\n"
"loc_FFE944C8:\n"                           
                                        
                "LDR     R3, =0x7E568\n"
                "LDR     R1, [R2,#4]\n"
                "LDR     R0, [R3]\n"
                "BL      sub_FFEA7E0C\n"
                "LDR     R0, [SP]\n"
                "BL      sub_FFE93D70\n"
"loc_FFE944E0:\n"                           
                "LDR     R3, =0x7E56C\n"
                "MOV     R1, R4\n"
                "LDR     R0, [R3]\n"
                "MOV     R2, #0\n"
                "BL      sub_FFEA8524\n"
                "TST     R0, #1\n"
                "BEQ     loc_FFE94384\n"
                "LDR     R0, =0xFFE93CF0\n"
                "MOV     R1, #0x400\n"
                "BL      sub_FFEB5664\n"
                "BL      sub_FFEA9AE8\n"
                "ADD     SP, SP, #4\n"
                "LDMFD   SP!, {R4,PC}\n"
	);
}

/*************************************************************/
void __attribute__((naked,noinline)) exp_drv_task(){
 asm volatile(
"                STMFD   SP!, {R4-R8,LR}\n"
"                SUB     SP, SP, #0x20\n"
"                ADD     R7, SP, #4\n"
"                B       loc_FFD1B328\n"
"loc_FFD1AE28:\n"
"                CMP     R2, #0x22\n"
"                BNE     loc_FFD1AE40\n"
"                LDR     R0, [R12,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R12,#0x88]\n"
"                B       loc_FFD1AEA4\n"
"loc_FFD1AE40:\n"
"                CMP     R2, #0x1D\n"
"                BNE     loc_FFD1AE54\n"
"                MOV     R0, R12\n"
"                BL      sub_FFD1ACE8\n"
"                B       loc_FFD1AE94\n"
"loc_FFD1AE54:\n"
"                CMP     R2, #0x1E\n"
"                BNE     loc_FFD1AE68\n"
"                MOV     R0, R12\n"
"                BL      sub_FFD1AD44\n"
"                B       loc_FFD1AE94\n"
"loc_FFD1AE68:\n"
"                SUB     R3, R2, #0x1F\n"
"                CMP     R3, #1\n"
"                BHI     loc_FFD1AE80\n"
"                MOV     R0, R12\n"
"                BL      sub_FFD1ADA0\n"
"                B       loc_FFD1AE94\n"
"loc_FFD1AE80:\n"
"                CMP     R2, #0x21\n"
"                BNE     loc_FFD1AEB0\n"
"                BL      sub_FFCE1DB4\n"
"                BL      sub_FFCE4EEC\n"
"                BL      sub_FFCE4124\n"
"loc_FFD1AE94:\n"
"                LDR     R3, [SP,#4]\n"
"                LDR     R0, [R3,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R3,#0x88]\n"
"loc_FFD1AEA4:\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD1683C\n"
"                B       loc_FFD1B328\n"
"loc_FFD1AEB0:\n"
"                CMP     R2, #0xD\n"
"                MOV     R8, #1\n"
"                BNE     loc_FFD1AF20\n"
"                LDR     R1, [R12,#0x7C]\n"
"                ADD     R1, R1, R1,LSL#1\n"
"                ADD     R1, R12, R1,LSL#2\n"
"                ADD     R6, SP, #0x14\n"
"                SUB     R1, R1, #8\n"
"                MOV     R2, #0xC\n"
"                MOV     R0, R6\n"
"                BL      _memcpy\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD192EC\n"
"                LDR     R3, [SP,#4]\n"
"                LDR     R1, [R3,#0x7C]\n"
"                LDR     R2, [R3,#0x8C]\n"
"                ADD     R0, R3, #4\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R3,#0x88]\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD195BC\n"
"                LDR     R3, [SP,#4]\n"
"                ADD     R0, R3, #4\n"
"                LDR     R1, [R3,#0x7C]\n"
"                LDR     R2, [R3,#0x94]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R3,#0x90]\n"
"                B       loc_FFD1B270\n"
"loc_FFD1AF20:\n"
"                SUB     R3, R2, #0xE\n"
"                CMP     R3, #1\n"
"                BHI     loc_FFD1AFDC\n"
"                ADD     R6, SP, #0x14\n"
"                ADD     R5, SP, #8\n"
"                MOV     R0, R12\n"
"                MOV     R1, R6\n"
"                MOV     R2, R5\n"
"                BL      sub_FFD196B0\n"
"                MOV     R4, R0\n"
"                CMP     R4, #5\n"
"                CMPNE   R4, #1\n"
"                BNE     loc_FFD1AF74\n"
"                LDR     R12, [SP,#4]\n"
"                MOV     R0, R5\n"
"                LDR     R1, [R12,#0x7C]\n"
"                MOV     R2, R4\n"
"                LDR     R3, [R12,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R12,#0x88]\n"
"                B       loc_FFD1AFAC\n"
"loc_FFD1AF74:\n"
"                CMP     R4, #6\n"
"                CMPNE   R4, #2\n"
"                BNE     loc_FFD1AFBC\n"
"                LDR     R12, [SP,#4]\n"
"                MOV     R0, R5\n"
"                MOV     R1, R8\n"
"                MOV     R2, R4\n"
"                LDR     R3, [R12,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R12,#0x88]\n"
"                MOV     R1, R6\n"
"                LDR     R0, [SP,#4]\n"
"                MOV     R2, R5\n"
"                BL      sub_FFD1A948\n"
"loc_FFD1AFAC:\n"
"                MOV     R1, R4\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD1AC7C\n"
"                B       loc_FFD1B270\n"
"loc_FFD1AFBC:\n"
"                LDR     R12, [SP,#4]\n"
"                MOV     R2, R4\n"
"                ADD     R0, R12, #4\n"
"                LDR     R1, [R12,#0x7C]\n"
"                LDR     R3, [R12,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R12,#0x88]\n"
"                B       loc_FFD1B270\n"
"loc_FFD1AFDC:\n"
"                SUB     R3, R2, #0x19\n"
"                CMP     R3, #1\n"
"                BHI     loc_FFD1B034\n"
"                LDR     R1, [R12,#0x7C]\n"
"                ADD     R1, R1, R1,LSL#1\n"
"                ADD     R1, R12, R1,LSL#2\n"
"                ADD     R6, SP, #0x14\n"
"                SUB     R1, R1, #8\n"
"                MOV     R2, #0xC\n"
"                MOV     R0, R6\n"
"                BL      _memcpy\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD187A0\n"
"                LDR     R3, [SP,#4]\n"
"                ADD     R0, R3, #4\n"
"                LDR     R1, [R3,#0x7C]\n"
"                LDR     R2, [R3,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R3,#0x88]\n"
"                LDR     R0, [SP,#4]\n"
"                BL      sub_FFD18AC0\n"
"                B       loc_FFD1B270\n"
"loc_FFD1B034:\n"
"                ADD     R6, SP, #0x14\n"
"                ADD     R1, R12, #4\n"
"                MOV     R2, #0xC\n"
"                MOV     R0, R6\n"
"                BL      _memcpy\n"
"                LDR     R12, [SP,#4]\n"
"                LDR     R3, [R12]\n"
"                MOV     R2, R12\n"
"                CMP     R3, #0x1C\n"
"                LDRLS   PC, [PC,R3,LSL#2]\n"
"                B       loc_FFD1B25C\n"
"                .long loc_FFD1B0D4\n"
"                .long loc_FFD1B0E0\n"
"                .long loc_FFD1B0EC\n"
"                .long loc_FFD1B0EC\n"
"                .long loc_FFD1B0D4\n"
"                .long loc_FFD1B0E0\n"
"                .long loc_FFD1B0EC\n"
"                .long loc_FFD1B0EC\n"
"                .long loc_FFD1B110\n"
"                .long loc_FFD1B110\n"
"                .long loc_FFD1B230\n"
"                .long loc_FFD1B23C\n"
"                .long loc_FFD1B24C\n"
"                .long loc_FFD1B25C\n"
"                .long loc_FFD1B25C\n"
"                .long loc_FFD1B25C\n"
"                .long loc_FFD1B0F8\n"
"                .long loc_FFD1B104\n"
"                .long loc_FFD1B120\n"
"                .long loc_FFD1B12C\n"
"                .long loc_FFD1B164\n"
"                .long loc_FFD1B19C\n"
"                .long loc_FFD1B1D4\n"
"                .long loc_FFD1B20C\n"
"                .long loc_FFD1B20C\n"
"                .long loc_FFD1B25C\n"
"                .long loc_FFD1B25C\n"
"                .long loc_FFD1B218\n"
"                .long loc_FFD1B224\n"
"loc_FFD1B0D4:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD1719C\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B0E0:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD17440\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B0EC:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD176B4\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B0F8:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD179B0\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B104:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD17C18\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B110:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD17E18_my\n" // ->
"                MOV     R8, #0\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B120:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD17F78\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B12C:\n"
"                LDRH    R1, [R2,#4]\n"
"                LDR     R3, =0x2ABF0\n"
"                STRH    R1, [SP,#0x14]\n"
"                LDRH    R1, [R3,#6]\n"
"                STRH    R1, [SP,#0x1A]\n"
"                LDRH    R1, [R3,#2]\n"
"                STRH    R1, [SP,#0x16]\n"
"                LDRH    R3, [R3,#4]\n"
"                STRH    R3, [SP,#0x18]\n"
"                MOV     R0, R2\n"
"                LDRH    R2, [R2,#0xC]\n"
"                STRH    R2, [SP,#0x1C]\n"
"                BL      sub_FFD18270\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B164:\n"
"                MOV     R0, R2\n"
"                LDRH    R2, [R2,#4]\n"
"                LDR     R3, =0x2ABF0\n"
"                STRH    R2, [SP,#0x14]\n"
"                LDRH    R2, [R3,#8]\n"
"                STRH    R2, [SP,#0x1C]\n"
"                LDRH    R1, [R3,#2]\n"
"                STRH    R1, [SP,#0x16]\n"
"                LDRH    R2, [R3,#4]\n"
"                STRH    R2, [SP,#0x18]\n"
"                LDRH    R3, [R3,#6]\n"
"                STRH    R3, [SP,#0x1A]\n"
"                BL      sub_FFD18398\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B19C:\n"
"                LDR     R3, =0x2ABF0\n"
"                LDRH    R1, [R3]\n"
"                STRH    R1, [SP,#0x14]\n"
"                MOV     R0, R2\n"
"                LDRH    R2, [R2,#6]\n"
"                STRH    R2, [SP,#0x16]\n"
"                LDRH    R2, [R3,#8]\n"
"                STRH    R2, [SP,#0x1C]\n"
"                LDRH    R1, [R3,#4]\n"
"                STRH    R1, [SP,#0x18]\n"
"                LDRH    R3, [R3,#6]\n"
"                STRH    R3, [SP,#0x1A]\n"
"                BL      sub_FFD1845C\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B1D4:\n"
"                LDR     R3, =0x2ABF0\n"
"                LDRH    R1, [R3,#6]\n"
"                STRH    R1, [SP,#0x1A]\n"
"                LDRH    R1, [R3]\n"
"                STRH    R1, [SP,#0x14]\n"
"                LDRH    R1, [R3,#2]\n"
"                STRH    R1, [SP,#0x16]\n"
"                LDRH    R3, [R3,#4]\n"
"                STRH    R3, [SP,#0x18]\n"
"                MOV     R0, R2\n"
"                LDRH    R2, [R2,#0xC]\n"
"                STRH    R2, [SP,#0x1C]\n"
"                BL      sub_FFD18514\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B20C:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD185C4\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B218:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD18C0C\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B224:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD18E08\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B230:\n"
"                MOV     R0, R2\n"
"                BL      sub_FFD18FC4\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B23C:\n"
"                MOV     R0, R2\n"
"                MOV     R1, #0\n"
"                BL      sub_FFD191AC\n"
"                B       loc_FFD1B258\n"
"loc_FFD1B24C:\n"
"                MOV     R0, R2\n"
"                MOV     R1, #1\n"
"                BL      sub_FFD191AC\n"
"loc_FFD1B258:\n"
"                LDR     R12, [SP,#4]\n"
"loc_FFD1B25C:\n"
"                ADD     R0, R12, #4\n"
"                LDR     R1, [R12,#0x7C]\n"
"                LDR     R2, [R12,#0x8C]\n"
"                MOV     LR, PC\n"
"                LDR     PC, [R12,#0x88]\n"
"loc_FFD1B270:\n"
"                CMP     R8, #1\n"
"                BNE     loc_FFD1B298\n"
"                LDR     R1, [SP,#4]\n"
"                LDR     R3, [R1,#0x7C]\n"
"                ADD     R3, R3, R3,LSL#1\n"
"                ADD     R1, R1, R3,LSL#2\n"
"                MOV     R0, R6\n"
"                SUB     R1, R1, #8\n"
"                BL      sub_FFD16E54\n"
"                B       loc_FFD1B314\n"
"loc_FFD1B298:\n"
"                LDR     R3, [SP,#4]\n"
"                LDR     R2, [R3]\n"
"                CMP     R2, #9\n"
"                BNE     loc_FFD1B2E0\n"
"                MOV     R4, #0\n"
"                MOV     R1, #1\n"
"                MOV     R2, R1\n"
"                MOV     R3, R1\n"
"                MOV     R0, R4\n"
"                STR     R4, [SP]\n"
"                BL      sub_FFD16D98\n"
"                MOV     R1, #1\n"
"                MOV     R0, R4\n"
"                MOV     R2, R1\n"
"                MOV     R3, R1\n"
"                STR     R4, [SP]\n"
"                BL      sub_FFD16FF0\n"
"                B       loc_FFD1B314\n"
"loc_FFD1B2E0:\n"
"                MOV     R4, #1\n"
"                MOV     R0, R4\n"
"                MOV     R1, R4\n"
"                MOV     R2, R4\n"
"                MOV     R3, R4\n"
"                STR     R4, [SP]\n"
"                BL      sub_FFD16D98\n"
"                MOV     R0, R4\n"
"                MOV     R1, R0\n"
"                MOV     R2, R0\n"
"                MOV     R3, R0\n"
"                STR     R4, [SP]\n"
"                BL      sub_FFD16FF0\n"
"loc_FFD1B314:\n"
"                LDR     R2, =0x2AC3C\n"
"                MOV     R3, #0\n"
"                LDR     R0, [SP,#4]\n"
"                STR     R3, [R2]\n"
"                BL      sub_FFD1683C\n"
"loc_FFD1B328:\n"
"                LDR     R3, =0x2ABE4\n"
"                MOV     R2, #0\n"
"                LDR     R0, [R3]\n"
"                MOV     R1, R7\n"
"                BL      sub_FFEA8524\n"// ReceiveMessageQueue
"                LDR     R12, [SP,#4]\n"
"                LDR     R2, [R12]\n"
"                CMP     R2, #0x23\n"
"                BNE     loc_FFD1AE28\n"
"                MOV     R0, R12\n"
"                BL      sub_FFD1683C\n"
"                LDR     R3, =0x2ABE0\n"
"                MOV     R1, #1\n"
"                LDR     R0, [R3]\n"
"                BL      sub_FFEA7E0C\n" // SetEventFlag
"                BL      sub_FFEA9AE8\n"
"                ADD     SP, SP, #0x20\n"
"                LDMFD   SP!, {R4-R8,PC}\n"
 );
}

void __attribute__((naked,noinline)) sub_FFD17E18_my() {
 asm volatile(
"                STMFD   SP!, {R4-R6,LR}\n"
"                LDR     R3, =0x2ABE0\n"
"                MOV     R4, R0\n"
"                MOV     R1, #0x3E\n"
"                LDR     R0, [R3]\n"
"                BL      sub_FFEA7FA8\n" // ClearEventFlag
"                MOV     R1, #0\n"
"                LDRSH   R0, [R4,#4]\n"
"                BL      sub_FFD16970\n"
"                MOV     R6, R0\n"
"                LDRSH   R0, [R4,#6]\n"
"                BL      sub_FFD16AD8\n"
"                LDRSH   R0, [R4,#8]\n"
"                BL      sub_FFD16B74\n"
"                LDRSH   R0, [R4,#0xA]\n"
"                BL      sub_FFD16C10\n"
"                LDRSH   R0, [R4,#0xC]\n"
"                BL      sub_FFD16CAC\n"
"                LDR     R3, [R4]\n"
"                CMP     R3, #9\n"
"                MOV     R5, R0\n"
"                MOVEQ   R5, #0\n"
"                MOVEQ   R6, R5\n"
"                CMP     R6, #1\n"
"                BNE     loc_FFD17E9C\n"
"                MOV     R2, #2\n"
"                LDRSH   R0, [R4,#4]\n"
"                LDR     R1, =0xFFD16890\n"
"                BL      sub_FFE6CC1C\n"
"                LDR     R2, =0x2AC30\n"
"                MOV     R3, #0\n"
"                STR     R3, [R2]\n"
"                B       loc_FFD17EA0\n"
"loc_FFD17E9C:\n"
"                BL      sub_FFD16D48\n"
"loc_FFD17EA0:\n"
"                STRH    R0, [R4,#4]\n"
"                CMP     R5, #1\n"
"                BNE     loc_FFD17EC0\n"
"                LDRSH   R0, [R4,#0xC]\n"
"                LDR     R1, =0xFFD16954\n"
"                MOV     R2, #0x20\n"
"                BL      sub_FFD1713C\n"
"                B       loc_FFD17EC4\n"
"loc_FFD17EC0:\n"
"                BL      sub_FFD16D88\n"
"loc_FFD17EC4:\n"
"                STRH    R0, [R4,#0xC]\n"
"                LDRSH   R0, [R4,#6]\n"
"                BL      sub_FFCE1A30_my\n" // ->
"                LDRSH   R0, [R4,#8]\n"
"                MOV     R1, #1\n"
"                BL      sub_FFCE3CE4\n"
"                ADD     R0, R4, #8\n"
"                MOV     R1, #0\n"
"                BL      sub_FFCE3DA4\n"
"                LDRSH   R0, [R4,#0xE]\n"
"                BL      sub_FFD055A0\n"
"                CMP     R6, #1\n"
"                BNE     loc_FFD17F28\n"
"                LDR     R3, =0x2ABE0\n"
"                MOV     R2, #0xBB0\n"
"                LDR     R0, [R3]\n"
"                MOV     R1, #2\n"
"                ADD     R2, R2, #8\n"
"                BL      sub_FFEA7DFC\n"
"                TST     R0, #1\n"
"                BEQ     loc_FFD17F28\n"
"                MOV     R1, #0x4A0\n"
"                LDR     R0, =0xFFD167E8\n" // "expdrv.c"
"                ADD     R1, R1, #3\n"
"                BL      sub_FFEB5664\n" //DebugAssert
"loc_FFD17F28:\n"
"                CMP     R5, #1\n"
"                LDMNEFD SP!, {R4-R6,PC}\n"
"                LDR     R3, =0x2ABE0\n"
"                MOV     R2, #0xBB0\n"
"                LDR     R0, [R3]\n"
"                MOV     R1, #0x20\n"
"                ADD     R2, R2, #8\n"
"                BL      sub_FFEA7DFC\n"
"                TST     R0, #1\n"
"                LDMEQFD SP!, {R4-R6,PC}\n"
"                MOV     R1, #0x4A0\n"
"                LDR     R0, =0xFFD167E8\n" // "expdrv.c"
"                ADD     R1, R1, #8\n"
"                LDMFD   SP!, {R4-R6,LR}\n"
"                B       sub_FFEB5664\n" //DebugAssert
	);
}

void __attribute__((naked,noinline)) sub_FFCE1A30_my () {
 asm volatile(
"                STMFD   SP!, {R4,LR}\n"
"                LDR     R3, =0x594C\n"
"                LDR     R2, [R3]\n"
"                MOV     R1, #0x168\n"
"                MOV     R3, R0,LSL#16\n"
"                CMP     R2, #1\n"
"                ADD     R1, R1, #3\n"
"                LDR     R0, =0xFFCE124C\n" // "Shutter.c"
"                MOV     R4, R3,ASR#16\n"
"                BEQ     loc_FFCE1A5C\n"
"                BL      sub_FFEB5664\n" //DebugAssert
"loc_FFCE1A5C:\n"
"                MOV     R1, #0x170\n"
"                CMN     R4, #0xC00\n"
"                LDR     R3, =0x1177E\n"
"                LDR     R0, =0xFFCE124C\n" // "Shutter.c"
"                ADD     R1, R1, #1\n"
"                LDREQSH R4, [R3]\n"
"                LDRNE   R3, =0x1177E\n"
"                CMN     R4, #0xC00\n"
"                STRH    R4, [R3]\n"
"                BNE     loc_FFCE1A88\n"
"                BL      sub_FFEB5664\n" //DebugAssert
"loc_FFCE1A88:\n"
"                MOV     R0, R4\n"
//"                BL      sub_FFCE2B80\n" // apex2us\n"
"                BL      apex2us\n"
"                MOV     R4, R0\n"
"                BL      sub_FFD6CC5C\n"
"                MOV     R0, R4\n"
"                BL      sub_FFD83504\n"
"                MOV     R1, #0x174\n"
"                TST     R0, #1\n"
"                ADD     R1, R1, #2\n"
"                LDR     R0, =0xFFCE124C\n" // "Shutter.c"
"                LDMEQFD SP!, {R4,PC}\n"
"                LDMFD   SP!, {R4,LR}\n"
"                B       sub_FFEB5664\n" //DebugAssert
 );
}
